<template>
    <Dialog :app-dialog="appDialog">
        <el-tabs v-model="tabsActiveName" class="tabs_box">
            <el-tab-pane label="个人客户" name="personal">
                <ImportForm
                    ref="personalRef"
                    :multiple="multiple"
                    :batch-import-type="batchImportType"
                    @submit="onSubmitParent" />
            </el-tab-pane>
            <el-tab-pane label="企业客户" name="enterprise">
                <ImportForm
                    ref="enterpriseRef"
                    :multiple="multiple"
                    :batch-import-type="batchImportType"
                    :customer-type="2"
                    @submit="onSubmitParent" />
            </el-tab-pane>
        </el-tabs>
    </Dialog>
</template>

<script lang="ts" setup>
import ImportForm from './ImportForm.vue';
import Dialog from '@/components/Dialog.vue';
import { ref } from 'vue';
interface Props {
    multiple?: any;
    batchImportType?: any;
}
withDefaults(defineProps<Props>(), {
    multiple: false, // 是否多选
    batchImportType: 1 // 批量导入类型 客户列表-1 客户公海-2 客户分配-3
});
const emit = defineEmits(['save']);
const personalRef = ref<any>(null);
const enterpriseRef = ref<any>(null);
const tabsActiveName = ref('personal');
let clickEvent: any = null;
// 关闭弹框
const cancelHandel = () => {
    appDialog.value.visible = false;
};
// 保存
const submitHandel = e => {
    clickEvent = e;
    tabsActiveName.value == 'personal' ? personalRef.value.onSubmit() : enterpriseRef.value.onSubmit();
};
const onSubmitParent = () => {
    emit('save', clickEvent);
    cancelHandel();
};
const appDialog = ref<any>({
    visible: false,
    title: '批量导入',
    width: '800px',
    cancel: cancelHandel,
    submit: submitHandel,
    cancelText: '取消',
    submitText: '保存'
});
defineExpose({
    appDialog
});
</script>

<style lang="scss" scoped>
.tabs_box {
    :deep(.el-tabs__item) {
        color: #969696;
    }

    :deep(.is-active) {
        // font-weight: 600;
        color: #ff6b00;
    }

    :deep(.el-tabs__header) {
        margin-bottom: 0;
    }
}

.formData {
    max-height: 50vh;
    overflow-y: scroll;
    padding: 12px 30px 50px 0;

    .upload-content {
        overflow: hidden;
        box-sizing: border-box;
        position: relative;
        display: inline-block;
        vertical-align: middle;
        width: 180px;
        height: 36px;
        border: 1px solid #eaeaea;
        margin-bottom: 6px;

        .upload {
            box-sizing: border-box;
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 9;
            opacity: 0;
        }

        .upload-box {
            position: relative;
            width: 180px;
            height: 36px;
            border-radius: 4px;
            line-height: 36px;
            text-align: center;
            font-size: 14px;
            font-family: STHeitiSC-Light, STHeitiSC;
            color: #969696;
            display: flex;
            align-items: center;
            justify-content: center;

            span {
                margin-left: 9px;
            }
        }

        .upload-file-box {
            display: flex;
            justify-content: space-between;
            border-radius: 4px;
            border: 1px solid #eaeaea;
            width: 180px;
            height: 36px;
            line-height: 36px;

            .left {
                font-size: 14px;
                font-family: STHeitiSC-Light, STHeitiSC;
                color: #33302d;
                padding-left: 10px;

                span {
                    vertical-align: middle;
                }

                img {
                    margin-top: 8px;
                    width: 20px;
                    height: 20px;
                    margin-right: 4px;
                    vertical-align: middle;
                }
            }

            .right {
                cursor: pointer;
                width: 12px;
                height: 12px;
                margin-right: 10px;
                margin-top: 12px;
            }
        }
    }

    .download {
        font-size: 12px;
        font-family: STHeitiSC-Light, STHeitiSC;
        color: #ff6b00;

        // margin-left: 10px;
        cursor: pointer;
    }

    .upload-desc {
        margin-top: 6px;

        // background: #f9f9f9;
        border-radius: 1px;
        font-size: 12px;
        font-family: STHeitiSC-Light, STHeitiSC;
        color: #696969;
        padding: 4px 8px;
        line-height: 16px;
    }

    .tabs-box {
        margin-bottom: 7px;

        div {
            display: inline-block;
            background: #fffaf9;
            border-radius: 2px;
            border: 1px solid #ffc69e;
            justify-content: center;
            align-items: center;
            padding: 0 4px;
            line-height: 22px;
            height: 22px;
            font-size: 14px;
            font-family: STHeitiSC-Light, STHeitiSC;
            font-weight: 300;
            color: #ff6b00;
            margin-right: 10px;
            margin-bottom: 7px;

            .del-icon {
                margin-left: 8px;
                vertical-align: middle;
                cursor: pointer;
            }
        }
    }

    .yuangong-list {
        div {
            display: inline-block;
            vertical-align: middle;
            background: #fffaf9;
            border-radius: 1px;
            margin-right: 10px;
            margin-bottom: 10px;
            padding: 4px 8px;
            line-height: 22px;
            box-sizing: border-box;

            img {
                width: 10px;
                height: 12px;
            }

            .del_icon {
                width: 12px;
                height: 12px;
                cursor: pointer;
            }

            span {
                margin: 0 10px;
                font-size: 14px;
                font-family: STHeitiSC-Light, STHeitiSC;
                color: #35383a;
            }
        }
    }
}

.formData::-webkit-scrollbar {
    display: none;
}
</style>

<style>
.upload-content .el-upload {
    display: block !important;
}

.upload-content .el-form-item__content {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}
</style>
